#ifndef DAUPROXY_CLIENT_DAUPROXYAPI_H
#define DAUPROXY_CLIENT_DAUPROXYAPI_H

#include "dauproxy.h"

namespace dauproxy_api_func
{
    /**
     * Defines all api function types for libdauproxy.so. These types define in here because we are use dynamic linker
     * loader for loading libdauproxy.so. You can check the dauproxy.h file for more details about api documentation.
     * */

    typedef int (*ProxySetLibraryPath)(string libPath);
    typedef int (*ProxyInitLibrary)();
    typedef int (*ProxyReleaseLibrary)();

    typedef int (*ProxyAddDevice)(_proxy_dev_info& devinfo, string &uuid);
    typedef int (*ProxyAddDevicePlus)(_proxy_dev_info& devinfo, string dev_uuid);
    typedef int (*ProxyLogout)(string dev_uuid);
    typedef int (*ProxyLogin)(string dev_uuid);
    typedef int (*ProxyDeleteDevice)(string uuid);
    typedef int (*ProxyGetDeviceInfo)(string dev_uuid, _dau_device_info &device_info);
    typedef int (*ProxyGetDevChannelInfo)( string dev_uuid, _device_channel_info& channel_info);

    typedef int (*ProxyGetDeviceState)(string uuid);

    typedef int (*ProxySetAlarmCallback)(string dev_uuid,Proxy_MessageCallback callback_func, void* pUser);
    typedef int (*ProxySetupAlarmChan)(string dev_uuid, _setup_alarm_info* lpSetupParam,
            const char* pData, uint32_t dwDataLen);
    typedef int (*ProxyStopAlarmChan)(string dev_uuid);

    typedef int (*ProxyStartStream)(string dev_uuid,string channel,string subchannel,
            string streamurl, string& stream_uuid);
    typedef int (*ProxyStopStream)(string dev_uuid, string channel, string subchannel,string stream_uuid);

    typedef int (*ProxyGetOsdShowString)(string dev_uuid, string channel, _proxy_showstring_info &osd_info);
    typedef int (*ProxySetOsdShowString)(string dev_uuid, string channel, _proxy_showstring_info& osd_info);

    typedef int (*ProxyPtzControl)(string dev_uuid, string channel, int command, int param);
    typedef int (*ProxyPtzCruiseControl)(string dev_uuid, string channel, int command, int cruiseroute, int cruiseid, int param);
    typedef int (*ProxySdapFindDevicePlus)(_proxy_dev_type _dev_type, string& _json_str, int _find_time);
    typedef int (*ProxyGetPresetInfos)(string dev_uuid, string channel,_ptz_preset_list_info &preset_infos);
    typedef int (*ProxyGetLiveStreamUrl)(string dev_uuid, string channel, string subchannel,  string& stream_url);
    typedef int (*ProxyGetVodStreamUrl)(string dev_uuid, string channel, string subchannel, string begintime, string endtime, uint32_t  vod_type, string& stream_url);
    typedef int (*ProxySetPresetName)(string dev_uuid, string channel, int preset_id, string preset_name);
    typedef int (*ProxyMakeKeyFrame)(string dev_uuid, string channel, string subchannel);
    typedef int (*ProxyQueryRecordInfos)(string dev_uuid, string channel, string subchannel, string begintime, string endtime, uint32_t vod_type, _record_list_info& record_list);
}

class DauProxyApi
{
private:
    DauProxyApi();
    ~DauProxyApi();
    void *pHandle;
public:
    dauproxy_api_func::ProxySetLibraryPath ProxySetLibraryPath;
    dauproxy_api_func::ProxyInitLibrary ProxyInitLibrary;
    dauproxy_api_func::ProxyReleaseLibrary ProxyReleaseLibrary;

    dauproxy_api_func::ProxyAddDevice ProxyAddDevice;
    dauproxy_api_func::ProxyAddDevicePlus ProxyAddDevicePlus;
    dauproxy_api_func::ProxyLogin ProxyLogin;
    dauproxy_api_func::ProxyLogout ProxyLogout;
    dauproxy_api_func::ProxyDeleteDevice ProxyDeleteDevice;
    dauproxy_api_func::ProxyGetDeviceInfo ProxyGetDeviceInfo;
    dauproxy_api_func::ProxyGetDevChannelInfo ProxyGetDevChannelInfo;

    dauproxy_api_func::ProxyGetDeviceState ProxyGetDeviceState;

    dauproxy_api_func::ProxySetAlarmCallback ProxySetAlarmCallback;
    dauproxy_api_func::ProxySetupAlarmChan ProxySetupAlarmChan;
    dauproxy_api_func::ProxyStopAlarmChan ProxyStopAlarmChan;

    dauproxy_api_func::ProxyStartStream ProxyStartStream;
    dauproxy_api_func::ProxyStopStream ProxyStopStream;

    dauproxy_api_func::ProxyGetOsdShowString ProxyGetOsdShowString;
    dauproxy_api_func::ProxySetOsdShowString ProxySetOsdShowString;

    dauproxy_api_func::ProxyPtzControl ProxyPtzControl;
    dauproxy_api_func::ProxyPtzCruiseControl ProxyPtzCruiseControl;

    dauproxy_api_func::ProxySdapFindDevicePlus ProxySdapFindDevicePlus;
    dauproxy_api_func::ProxyGetVodStreamUrl ProxyGetVodStreamUrl;
    dauproxy_api_func::ProxyGetLiveStreamUrl ProxyGetLiveStreamUrl;

    dauproxy_api_func::ProxyGetPresetInfos ProxyGetPresetInfos;

    dauproxy_api_func::ProxySetPresetName ProxySetPresetName;
    dauproxy_api_func::ProxyMakeKeyFrame ProxyMakeKeyFrame;
    dauproxy_api_func::ProxyQueryRecordInfos ProxyQueryRecordInfos;

public:
    static DauProxyApi* GetInstance();
    int Init();
};

#endif //DAUPROXY_CLIENT_DAUPROXYAPI_H
